from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from django.contrib.auth.models import Group,Permission
from rest_framework.permissions import IsAdminUser
from meiduo_admin.serializers.groups import Groupserializer
from meiduo_admin.utils import PageNum
from meiduo_admin.serializers.permissions import PerssionsSerializer

class GroupView(ModelViewSet):
    serializer_class = Groupserializer
    queryset = Group.objects.all()
    pagination_class = PageNum
    permission_classes = [IsAdminUser]


    def simple(self,request):
        #获取权限信息
        # 使用先前的序列化器
        data = Permission.objects.all()
        ser = PerssionsSerializer(data,many=True)
        return Response(ser.data)